package com.zhaokuner.parentstarter.handler;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * 类描述:
 *
 * @author 赵希坤 zhaoxikun
 * @date 2020/12/15 18:04
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 增加一个对web请求的拦截器
        // 获取 请求中的重要数
        registry.addWebRequestInterceptor(new HttpReqInfoWebRequestInterceptor());
    }

    @Override
    public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
        // 设置 异常拦截
        exceptionResolvers.add(0, new MyHandlerExceptionResolver());
    }
}